package com.yida.gwj.expend.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.yida.gwj.expend.domain.GwjMaintenanceFundsBusinessCommunity;
import com.yida.gwj.expend.enums.FlagStatusEnum;
import com.yida.gwj.expend.mapper.GwjMaintenanceFundsBusinessCommunityMapper;
import com.yida.gwj.expend.service.IGwjMaintenanceFundsBusinessCommunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务小区信息Service业务层处理
 *
 * @author lgp
 * @date 2023-02-20
 */
@Service
public class GwjMaintenanceFundsBusinessCommunityServiceImpl implements IGwjMaintenanceFundsBusinessCommunityService {
    @Autowired
    private GwjMaintenanceFundsBusinessCommunityMapper gwjMaintenanceFundsBusinessCommunityMapper;

    /**
     * 查询业务小区信息
     *
     * @param businessCommunityId 业务小区信息主键
     * @return 业务小区信息
     */
    @Override
    public GwjMaintenanceFundsBusinessCommunity selectGwjMaintenanceFundsBusinessCommunityByBusinessCommunityId(Long businessCommunityId) {
        return gwjMaintenanceFundsBusinessCommunityMapper.selectGwjMaintenanceFundsBusinessCommunityByBusinessCommunityId(businessCommunityId);
    }

    /**
     * 查询业务小区信息列表
     *
     * @param gwjMaintenanceFundsBusinessCommunity 业务小区信息
     * @return 业务小区信息
     */
    @Override
    public List<GwjMaintenanceFundsBusinessCommunity> selectGwjMaintenanceFundsBusinessCommunityList(GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity) {
        return gwjMaintenanceFundsBusinessCommunityMapper.selectGwjMaintenanceFundsBusinessCommunityList(gwjMaintenanceFundsBusinessCommunity);
    }

    /**
     * 新增业务小区信息
     *
     * @param gwjMaintenanceFundsBusinessCommunity 业务小区信息
     * @return 结果
     */
    //@CachePut(value = "gwj_intranet:maintenance_funds_business_community", key = "#gwjMaintenanceFundsBusinessCommunity.businessId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusinessCommunity insertGwjMaintenanceFundsBusinessCommunity(GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity) {
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessCommunityMapper.insertGwjMaintenanceFundsBusinessCommunity(gwjMaintenanceFundsBusinessCommunity), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessCommunityMapper.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(gwjMaintenanceFundsBusinessCommunity.getBizId());
    }

    /**
     * 修改业务小区信息
     *
     * @param gwjMaintenanceFundsBusinessCommunity 业务小区信息
     * @return 结果
     */
    // @CachePut(value = "gwj_intranet:maintenance_funds_business_community", key = "#gwjMaintenanceFundsBusinessCommunity.businessId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusinessCommunity updateGwjMaintenanceFundsBusinessCommunity(GwjMaintenanceFundsBusinessCommunity gwjMaintenanceFundsBusinessCommunity) {
        if (ObjectUtil.notEqual(gwjMaintenanceFundsBusinessCommunityMapper.updateGwjMaintenanceFundsBusinessCommunity(gwjMaintenanceFundsBusinessCommunity), FlagStatusEnum.SUC.getCode())) {
            return null;
        }
        return gwjMaintenanceFundsBusinessCommunityMapper.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(gwjMaintenanceFundsBusinessCommunity.getBizId());
    }

    // @CacheEvict(value = "gwj_intranet:maintenance_funds_business_community", key = "#businessId", condition = "#result == 1")
    @Override
    public int deleteGwjMaintenanceFundsBusinessCommunityByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessCommunityMapper.deleteGwjMaintenanceFundsBusinessCommunityByBusinessId(businessId);
    }

    // @Cacheable(value = "gwj_intranet:maintenance_funds_business_community", key = "#businessId", unless = "#result == null")
    @Override
    public GwjMaintenanceFundsBusinessCommunity selectGwjMaintenanceFundsBusinessCommunityByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessCommunityMapper.selectGwjMaintenanceFundsBusinessCommunityByBusinessId(businessId);
    }
}
